package org.lql.algo.codecrush.hot100.dynamicProgramming;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: liangqinglong
 * @date: 2025-09-13 20:34
 * @description: 118. 杨辉三角 <a href="https://leetcode.cn/problems/pascals-triangle/description/?envType=study-plan-v2&envId=top-100-liked">...</a>
 **/
public class Generate {

	public List<List<Integer>> generate(int numRows) {
		List<List<Integer>> res = new ArrayList<>();
		for (int i = 0; i < numRows; i++) {
			List<Integer> row = new ArrayList<>();
			for (int j = 0; j <= i; j++) {
				if (j == 0 || j == i) {
					row.add(1);
				} else {
					row.add(res.get(i - 1).get(j - 1) + res.get(i - 1).get(j));
				}
			}
			res.add(row);
		}
		return res;
	}

	public static void main(String[] args) {
		Generate generate = new Generate();
		List<List<Integer>> res = generate.generate(5);
		System.out.println(res);
	}
}
